home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
doors_2
/
scrlfqot.zip
/
SCRLFQOT.LST
< prev
next >
Wrap
File List
|
1991-09-06
|
14KB
|
266 lines
PAGE 1
09-06-91
17:59:06
Line# Source Line Microsoft FORTRAN Optimizing Compiler Version 5.00
1 C *********************************************************************
2 C *** This is a typical comment line. `!' denotes comment following *
3 C *** a FORTRAN statement. *
4 C *** *
5 C *** M/L Routine to build ALTERNATE Simplex quote.cq file using *
6 C *** CR+LF, CR+LF delineators. A quote line is defined as *
7 C *** anything in between. *
8 C *** *
9 C *** This was written in FORTRAN to prove it can be done! *
10 C *** *
11 C *** 'SAMPLE'C implies C null terminated string. *
12 C *********************************************************************
13
14 C *** Default first letter variable type:
15 IMPLICIT INTEGER*4 (a-z)
16
17 C *** Default over-rides:
18 CHARACTER*32 infile, outfile ! I/O pathspecs.
19 CHARACTER*4 qt_scan, test$ ! For 2 newline search.
20 CHARACTER*1 qt_scan_1 (4), temp$ ! For scanning text file.
21 CHARACTER*14 chris_stuff ! Validity check.
22 CHARACTER*5 r_tab ! Backspaces for screen.
23
24 INTEGER *2 status, qt_num
25
26 LOGICAL test
27
28 DIMENSION qt_loc (4096) ! Space internal in EXE.
29 EQUIVALENCE ( qt_scan, qt_scan_1(1) ) ! Common RAM space.
30
31 C *** `chris_stuff' is Laforet's null terminated validity check.
32 C *** `test$' is 2 newlines, or CR+LF+CR+LF.
33 C *** `qt_scan' is initialized to avoid an undefined variable.
34 C *** `r_tab' is a series of backspaces.
35 chris_stuff= 'Simplex Quote'C
36 test$= CHAR(13) // CHAR(10) // CHAR(13) // CHAR(10)
37 qt_scan= ' '
38 r_tab= CHAR(8) // CHAR(8) // CHAR(8) // CHAR(8) // CHAR(8)
39
40 PRINT *
41 PRINT *,' S_CR_LF_QOT version 1.02, (c) 1991 Fred Niemczenia.'
42 PRINT *,' Alternate quote file generator for Simplex BBS, which'
43 PRINT *,' is the copyrighted brainchild of Chris Laforet.'
44 PRINT *,' *** You may use this utility without charge. ***'
45 PRINT *
46
47 C *** PARSE command line.
48 numargs= NARGS ()
49 C *** MS-FORTRAN ver 5.0 compiler ERROR documented. NARGS returns
50 C *** 1 as a minimum value when there is no argument. Documentation
51 C *** implies 0 in section 5.3.3 of reference manual.
52 IF (numargs .LE. 1) GOTO 9990
53 CALL GETARG (1, infile, status)
54
55 C *** Test if infile exists. If not, exit!
56 INQUIRE (FILE= infile, EXIST= test)
57 IF ( .NOT. test ) THEN
58 PRINT *, ' I couldn''t find: ', infile
PAGE 2
09-06-91
17:59:06
Line# Source Line Microsoft FORTRAN Optimizing Compiler Version 5.00
59 PRINT *, ' Run me again and get it right this time!'
60 PRINT *
61 GOTO 9990
62 END IF
63
64 len1= INDEX (infile, '.q ') ! Both CAPS & Lower
65 len2= INDEX (infile, '.Q ') ! case.
66
67 IF ( len1 .EQ. 0 .AND. len2 .EQ. 0 ) THEN
68 PRINT *, infile, 'is an invalid name!'
69 PRINT *
70 GOTO 9990
71 ELSE IF ( len1 .GT. len2 ) THEN ! len? includes `.'
72 length= len1 ! For lower case.
73 ELSE
74 length= len2 ! For upper case.
75 END IF
76
77 outfile= infile(1:length) // 'cq' ! Concatenate ext.
78
79 C *********************************************************************
80 C *** So let's check for how many separate quotations there are. *
81 C *** NOTE: *
82 C *** (1) It is understood that each text file has actual text on *
83 C *** the first line. You can't start with a blank line. *
84 C *** (2) There can be more than one line per quote. SQUOTE assumes *
85 C *** ONE quote per line. SCRLFQOT does not! Most text editors *
86 C *** set a limit on line length, hence this program. *
87 C *** (3) Separate quotes are separated by a blank line. This implies*
88 C *** a CR+LF+CR+LF between quotes. Only ONE blank line is *
89 C *** allowed between quotes ( aka 2 newlines). *
90 C *** (4) The last line of the file MUST be a blank line. *
91 C *********************************************************************
92
93 OPEN (UNIT=10, FILE= infile, FORM= 'BINARY', ACCESS='SEQUENTIAL',
94 & STATUS= 'UNKNOWN')
95
96 C *********************************************************************
97 C *** First processing LOOP begins! Scan for CR+LF+CR+LF *
98 C *********************************************************************
99 qt_num= 1 ! Initialize qt counter.
100 i_rec= 0 ! Initialize pointer.
101 qt_loc(1)= 0 ! First pointer loc.
102 PRINT 9002 ! Processing Quote
103
104 DO WHILE ( .NOT. EOF(10) )
105 i_rec= i_rec + 1 ! Increment pointer.
106 qt_scan_1(1)= qt_scan_1(2) ! Byte shift left.
107 qt_scan_1(2)= qt_scan_1(3) ! Byte shift left.
108 qt_scan_1(3)= qt_scan_1(4) ! Byte shift left.
109 READ (10) qt_scan_1(4) ! Input a byte.
110 IF ( qt_scan .EQ. test$ ) THEN ! Remember common RAM.
111 qt_num= qt_num + 1 ! Increment qt counter.
112 qt_loc(qt_num)= i_rec ! Store raw pointer.
113 PRINT 9003, r_tab, qt_num-1
114 END IF
115 END DO
116
PAGE 3
09-06-91
17:59:06
Line# Source Line Microsoft FORTRAN Optimizing Compiler Version 5.00
117 CLOSE (10) ! Close the infile.
118 qt_num= qt_num - 1 ! Adj. end overcount.
119 C PRINT 9001, (qt_loc(i), i=1, qt_num) ! Debugging only!
120
121 C *********************************************************************
122 C *** First processing loop ends & second begins! *
123 C *********************************************************************
124
125 OPEN (UNIT=10, FILE= infile, FORM= 'BINARY', ACCESS='SEQUENTIAL',
126 & STATUS= 'UNKNOWN')
127
128 OPEN (UNIT=11, FILE=outfile, FORM= 'BINARY', ACCESS='SEQUENTIAL',
129 & STATUS= 'UNKNOWN')
130
131 PRINT *
132 PRINT *, ' Writing Header block: ', outfile
133
134 C *** Write the validity check & quote counter.
135 WRITE (11) chris_stuff, qt_num ! 14 bytes + 2 bytes.
136 C *** Calculate and write the pointers.
137 offset= 16 + (qt_num * 4) ! For header block.
138 DO 2000 i= 1, qt_num ! Begin loop.
139 pointer= qt_loc(i) +offset -(i-1) * 3 ! -4 +1 byte for 2
140 WRITE (11) pointer ! newlines & \0.
141 2000 CONTINUE ! End of Loop.
142
143 PRINT 9004 ! Writing Quote
144 DO 3000 i=1, qt_num + 1 ! Loop for each quote.
145 PRINT 9003, r_tab, i-1
146 DO 2500 j= qt_loc(i), qt_loc(i+1)-5 ! Loop within quote.
147 READ (10, END=2800) temp$ ! Process byte by byte.
148 WRITE (11) temp$
149 2500 CONTINUE
150 DO 2700 j= 1, 4
151 READ (10, END=2800,ERR=8000) temp$ ! Pass over 2 newlines.
152 2700 CONTINUE
153 2800 WRITE (11) ''C ! Append \0 (null).
154 3000 CONTINUE
155
156 CLOSE (10)
157 CLOSE (11)
158
159 C *********************************************************************
160 C *** Second processing loop ends! *
161 C *********************************************************************
162
163 PRINT *
164 PRINT *, ' Ho-Hum, I''m done!'
165 GOTO 9999
166
167 8000 PRINT *
168 PRINT *, ' An attempt to read past the end of the input file'
169 PRINT *, ' has occurred. The Probable cause is:'
170 PRINT *, ' (1) The first line does not contain text.'
171 PRINT *, ' (2) Quotes are separated by MORE than ONE blank'
172 PRINT *, ' line.'
173 PRINT *, ' (3) The file doesn''t end with ONE blank line.'
174 PRINT *, ' Please recheck your quote file.'
PAGE 4
09-06-91
17:59:06
Line# Source Line Microsoft FORTRAN Optimizing Compiler Version 5.00
175 GOTO 9999
176
177 9990 PRINT *, ' SCRLFQOT expects a command line agrument. Consider'
178 PRINT *, ' the following example:'
179 PRINT *
180 PRINT *, ' SCRLFQOT sample.q {ENTER}'
181 PRINT *
182 PRINT *, ' The argument must be a valid file in the current'
183 PRINT *, ' directory, and MUST have the extension "q". The'
184 PRINT *, ' routine will generate sample.cq in the current'
185 PRINT *, ' directory.'
186 9999 CONTINUE
187
188 9001 FORMAT (8(1X,Z8))
189 9002 FORMAT (1X,' Finding Quote: '\)
190 9003 FORMAT (A5,I5\)
191 9004 FORMAT (1X,' Writing Quote: '\)
192
193 END
main Local Symbols
Name Class Type Size Offset
TEST. . . . . . . . . . . local LOGICAL*4 4 0006
I_REC . . . . . . . . . . local INTEGER*4 4 000a
LENGTH. . . . . . . . . . local INTEGER*4 4 000e
OFFSET. . . . . . . . . . local INTEGER*4 4 0012
R_TAB . . . . . . . . . . local CHAR*5 5 0016
I . . . . . . . . . . . . local INTEGER*4 4 001c
J . . . . . . . . . . . . local INTEGER*4 4 0020
LEN1. . . . . . . . . . . local INTEGER*4 4 0024
LEN2. . . . . . . . . . . local INTEGER*4 4 0028
OUTFILE . . . . . . . . . local CHAR*32 32 002c
TEMP$ . . . . . . . . . . local CHAR*1 1 004c
NUMARGS . . . . . . . . . local INTEGER*4 4 004e
CHRIS_STUFF . . . . . . . local CHAR*14 14 0052
POINTER . . . . . . . . . local INTEGER*4 4 0060
QT_LOC. . . . . . . . . . local INTEGER*4 16384 0064
STATUS. . . . . . . . . . local INTEGER*2 2 4064
TEST$ . . . . . . . . . . local CHAR*4 4 4066
QT_NUM. . . . . . . . . . local INTEGER*2 2 406a
INFILE. . . . . . . . . . local CHAR*32 32 406c
QT_SCAN . . . . . . . . . local CHAR*4 4 0002
QT_SCAN_1 . . . . . . . . local CHAR*1 4 0002
Global Symbols
Name Class Type Size Offset
GETARG. . . . . . . . . . extern *** *** ***
NARGS . . . . . . . . . . extern INTEGER*4 *** ***
main. . . . . . . . . . . FSUBRT *** *** 0000
Code size = 05e9 (1513)
Data size = 050f (1295)
PAGE 5
09-06-91
17:59:06
Microsoft FORTRAN Optimizing Compiler Version 5.00
Bss size = 408c (16524)
No errors detected